package com.atos.howl.chaos.web.controller.register;

import com.atos.howl.chaos.pdm.dto.ChaosRegistryDTO;
import com.atos.howl.chaos.pdm.entity.User;
import com.atos.howl.chaos.pdm.mapper.UserMapper;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.util.UUID;


@Controller
@RequestMapping("/api/registerController")
public class RegisterController {

    @Resource
    private UserMapper userMapper;

    @PostMapping("/register")
    @ResponseBody
    public String register(@RequestBody ChaosRegistryDTO chaosRegistryDTO){
        User user = new User();
        user.setAccount(chaosRegistryDTO.getAccount());
        user.setPassword(chaosRegistryDTO.getPassword());
        String uuid = UUID.randomUUID().toString().replaceAll("-","");
        user.setUserUuid(uuid);
        userMapper.addUser(user);
        return "注册成功";
    }
}
